package com.cm.caseManagement.controller;


import com.cm.caseManagement.annotation.Log;
import com.cm.caseManagement.core.controller.BaseController;
import com.cm.caseManagement.core.domain.AjaxResult;
import com.cm.caseManagement.core.page.TableDataInfo;
import com.cm.caseManagement.pojo.entity.CmDashboardStatsSnaps;
import com.cm.caseManagement.pojo.enums.BusinessType;
import com.cm.caseManagement.service.ICmDashboardStatsSnapsService;
import com.cm.caseManagement.utils.poi.ExcelUtil;
import jakarta.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 统计看板快照Controller
 *
 * @author ruoyi
 * @date 2025-10-05
 */
@RestController
@RequestMapping("/caseManagement/snaps")
public class CmDashboardStatsSnapsController extends BaseController
{
    @Autowired
    private ICmDashboardStatsSnapsService cmDashboardStatsSnapsService;

    /**
     * 查询统计看板快照列表
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:snaps:list')")
    @GetMapping("/list")
    public TableDataInfo list(CmDashboardStatsSnaps cmDashboardStatsSnaps)
    {
        startPage();
        List<CmDashboardStatsSnaps> list = cmDashboardStatsSnapsService.selectCmDashboardStatsSnapsList(cmDashboardStatsSnaps);
        return getDataTable(list);
    }

    /**
     * 导出统计看板快照列表
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:snaps:export')")
    @Log(title = "统计看板快照", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CmDashboardStatsSnaps cmDashboardStatsSnaps)
    {
        List<CmDashboardStatsSnaps> list = cmDashboardStatsSnapsService.selectCmDashboardStatsSnapsList(cmDashboardStatsSnaps);
        ExcelUtil<CmDashboardStatsSnaps> util = new ExcelUtil<CmDashboardStatsSnaps>(CmDashboardStatsSnaps.class);
        util.exportExcel(response, list, "统计看板快照数据");
    }

    /**
     * 获取统计看板快照详细信息
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:snaps:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(cmDashboardStatsSnapsService.selectCmDashboardStatsSnapsById(id));
    }

    /**
     * 新增统计看板快照
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:snaps:add')")
    @Log(title = "统计看板快照", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CmDashboardStatsSnaps cmDashboardStatsSnaps)
    {
        return toAjax(cmDashboardStatsSnapsService.insertCmDashboardStatsSnaps(cmDashboardStatsSnaps));
    }

    /**
     * 修改统计看板快照
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:snaps:edit')")
    @Log(title = "统计看板快照", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CmDashboardStatsSnaps cmDashboardStatsSnaps)
    {
        return toAjax(cmDashboardStatsSnapsService.updateCmDashboardStatsSnaps(cmDashboardStatsSnaps));
    }

    /**
     * 删除统计看板快照
     */
    @PreAuthorize("@ss.hasPermi('caseManagement:snaps:remove')")
    @Log(title = "统计看板快照", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(cmDashboardStatsSnapsService.deleteCmDashboardStatsSnapsByIds(ids));
    }
}
